package com.changanw.jedis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class JedisPoolTest {
    public static void main(String[] args) {
        /*Jedis resource = null;
        //1、构造一个jedis连接池
        JedisPool jedisPool = new JedisPool("localhost", 6379);
        //2、从连接池中获取一个jedis连接
        resource = jedisPool.getResource();
        resource.auth("12345");
        try {
            //3、jedis操作
            String ping = resource.ping();
            System.out.println(ping);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            //4、归还连接
            if (resource != null){
                resource.close();
            }
        }*/
        Redis redis = new Redis();
        redis.execute(jedis -> {
            System.out.println(jedis.ping());
        });
    }
}
